"""
字典，不允许重复，新的会覆盖旧的
"""
# 空字典
my_dict = {}
my_dict1 = dict()

stu_score = {"czt": 99, "zh": 100, "ljx": 88}
czt_score = stu_score["czt"]
# print(czt_score)

stu_score_dict = {"czt": {"语文": 77, "英语": 88, "数学": 99},
                  "zh": {"语文": 97, "英语": 98, "数学": 99}
                  }

czt_math = stu_score_dict["czt"]["数学"]
# print(czt_math)

# 新增和修改 字典[key] = value 如果key不存在则为添加，如果存在则为修改
stu_score["tjy"] = 77
print(stu_score)
stu_score["tjy"] = 66
print(stu_score)

# 移除并获取 字典.pop(key)
tjy = stu_score.pop("tjy")
print(tjy)

# 字典.clean() 清空

# 获取全部key 字典.keys() 用于遍历
keys = stu_score.keys()
print(keys)

# 字典的遍历
for key in stu_score:
    print(key)
    print(stu_score[key])

emp_dict = {
    "王力宏": {"部门": "科技部", "工资": 3000, "级别": 1},
    "周杰伦": {"部门": "市场部", "工资": 5000, "级别": 2},
    "林俊杰": {"部门": "市场部", "工资": 7000, "级别": 3},
    "张学友": {"部门": "科技部", "工资": 4000, "级别": 1},
    "刘德华": {"部门": "市场部", "工资": 6000, "级别": 2},
}

for key in emp_dict:
    if emp_dict[key]["级别"] == 1:
        emp_dict[key]["级别"] += 1
        emp_dict[key]["工资"] += 1000

print(emp_dict)
# 遍历key
for key in stu_score:
    print(key)
# 遍历value
for value in stu_score.values():
    print(value)

# 遍历key和value
for key, value in stu_score.items():
    print(key, value)

# 遍历里面的元素
for item in stu_score.items():
    print(item)
